package com.lagou;

import com.alibaba.fastjson.JSON;
import com.lagou.dao.impl.CourseDao;
import com.lagou.dao.impl.CourseDaoimpl;
import com.lagou.pojo.Course;
import com.lagou.utils.DateUtils;

import org.junit.Test;

import java. util.List;

public class course {
    CourseDao courseDao = new CourseDaoimpl();
    @Test
    public  void  findCourseList(){

        List<Course> courseList = courseDao.findCourseList();
        //fastjson 对象转JSON方法
        String s= JSON.toJSONString(courseList);
        System.out.println(s);

//要把对象转换为JSON  返还成前端
    }
    @Test
    public void testCourseNameAndStatus(){
        List<Course> courseList = courseDao.findCourseNameAndStatus("微服务", "0");
        //json
        String s = JSON.toJSONString(courseList);
        System.out.println(s);
//
//
   }
    @Test
    public  void saveCourse(){
        Course course = new Course();
        course.setCourse_name("python高级");
        course.setCourse_description("非常高");
        course.setBrief("学会找");
        course.setTeacher_name("药水");
        course.setTeacher_info("java 非常good");
        course.setPreview_first_field("30讲");
        course.setPreview_second_field("88讲");
        course.setDiscounts(88.88);
        course.setPrice(188.8);
        course.setShare_title("哈哈哈");
        course.setShare_image_title("嘻嘻嘻");
        course.setShare_description("事实");
        course.setCourse_description("36jdadasd");
        course.setCourse_img_url("1231");
        course.setStatus(1);

        //工具类  时间格式化方法
        DateUtils dateUtils = new DateUtils();
        String dateFormart = DateUtils.getDateFormart();
        course.setUpdate_time(dateFormart);
        course.setCreate_time(dateFormart);

       int i= courseDao.saveCourseSales(course);
        System.out.println(i);
    }
}
